<?PHP 
require_once('common/config.php');
require_once('common/model.php');


$nick=$_POST['nick']; 
$password=$_POST['password'];

$nick=mysql_real_escape_string($nick);
$password=mysql_real_escape_string($password);
//$password=encrypt($password); 

$res = dameDatosLogin($nick, $password);

if (!($fila = mysql_fetch_array($res))) {
	header("Location: index");
}
else {
	$rango = $fila["rango"];
	//if ($rango == 'A') {
		$_SESSION["usuario"]=$nick;
		$_SESSION["idusuario"]=$fila["id_usuario"];
		$_SESSION["rango"]=$rango;
	/*	echo '<script language="JavaScript" type="text/javascript">
		history.back(-1); 
			</script>';*/
			header("Location: index");
	//} else if ($tipoUsu == 'U'){
	//	$_SESSION["user"]=$_POST["usuario"];
	//	$_SESSION["type"]=$tipoUsu;
	//	header("Location: ../index.php");
	//} else {
	//	header("Location: ../login.php");
	//}
}

?>